//
// Created by LiuYou on 2021/8/20.
//

#ifndef HIGHPERFORMANCELINUXSERVERPROGRAMMING_LINUX2_CONDITION_HPP
#define HIGHPERFORMANCELINUXSERVERPROGRAMMING_LINUX2_CONDITION_HPP


#include <pthread.h>


/** 封装条件变量的类。*/
class Condition {
public:
    /** 等待条件变量。*/
    bool wait();

    /** 唤醒等待条件变量的线程。*/
    bool signal();

public:
    Condition();

    ~Condition();

private:
    pthread_mutex_t mutex;
    pthread_cond_t condition;

};


#endif //HIGHPERFORMANCELINUXSERVERPROGRAMMING_LINUX2_CONDITION_HPP
